package com.dayang.homemaking.common.core.domain;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;

import java.util.List;

/**
 * @author: dayang
 * @since: 2024/9/14
 * @description: 通用分页查询参数
 */

@Data
public class PageQuery {
    @Schema(description = "页码", example = "1")
    @NotNull(message = "分页参数不能为空")
    private Long pageNum = 1L;

    @Schema(description = "每页大小", example = "10")
    @NotNull(message = "每页大小不能为空")
    @Max(value = 200,message = "每页最大为200")
    private Long pageSize = 10L;

    @Schema(description = "排序字段集合")
    @Size(max = 10, message = "排序字段最多10")
    @Valid
    private List<SortItem> sortItemList;

    @Data
    public static class SortItem{
        @Schema(description = "是否升序(true:升序|false:倒序)")
        @NotNull(message = "排序规则不能为空")
        private Boolean isAsc;

        @Schema(description = "排序字段")
        @NotBlank(message = "排序字段不能为空")
        private String column;
    }
}
